package com.stx.stcp.controller;

import com.stx.stcp.bean.AdminBean;
import com.stx.stcp.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class AdminController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("pub/back/login")
    public String login(HttpServletRequest request, AdminBean adminBean){
        AdminBean adminBean1 = adminService.login(adminBean.getZh(),adminBean.getPwd());
        if(adminBean1!=null){
            request.getSession().setAttribute("ADMIN",adminBean1);
            return "back/main";
        }else{
            return "back/index";
        }
    }

    @RequestMapping("pub/pri/logout")
    public String logout(HttpServletRequest request){
        request.getSession().removeAttribute("ADMIN");
        return "back/index";
    }

}
